/* Copyright (C) 
 * 
 * Disclaim
 * This program is the property of AI Speech Ltd. It shall be communicated to
 * authorized personnel only. It is not to be disclosed outside the group without
 * prior written consent. If you are not sure if you’re authorized to read this
 * program, please contact info@aispeech.com before reading.
 * 
 */

#ifndef ___WXM71___AISPEECH_WTK_UTILS_OFFINFO__HEADER___
#define ___WXM71___AISPEECH_WTK_UTILS_OFFINFO__HEADER___

#ifdef __cplusplus 
extern "C" {
#endif 

#ifndef OFF_TYPE 
#define OFF_TYPE unsigned int
#endif



typedef struct wtk_offinfo wtk_offinfo_t;


struct wtk_offinfo {
    OFF_TYPE *val;          ///< inforamtion for all item, FORMAT: id offset length, both unsigned short(2 bytes)
    int num;                ///< number of item 
};


wtk_offinfo_t* wtk_offinfo_new(int len);
int wtk_offinfo_delete(wtk_offinfo_t *info);


/**
 * @brief read offset information with given id
 *
 * @param tid target id
 * @param off output variable, receive offset value
 * @param len output variable, receive length value
 *
 * @return -1 for not found given id, otherwise return 0
 */
int wtk_offinfo_get(wtk_offinfo_t *info, int tid, OFF_TYPE *off, OFF_TYPE *len);


/**
 * @brief get i'th offinfo item
 */
int wtk_offinfo_at(wtk_offinfo_t *info, int i, OFF_TYPE *id, OFF_TYPE *off, OFF_TYPE *len);

/**
 * @brief load offet information
 */
struct wtk_source;
int wtk_offinfo_load(wtk_offinfo_t *info, struct wtk_source *s);


/**
 * @brief output off-information, for debugging
 */
int wtk_offinfo_print(wtk_offinfo_t *info);


#ifdef __cplusplus  
};
#endif

#endif


